#!/bin/sh
# chkconfig: 345 50 80
. /etc/init.d/functions
VIP=192.168.100.10
RIP=(
192.168.100.1
192.168.100.2
)
start() {
        ifconfig eth0:0 ${VIP}/24 up
        ipvsadm --clear
        ipvsadm --set 30 5 60
        ipvsadm -A -t ${VIP}:80 -s wrr
for ((i=0;i<${#RIP[*]};i++))
do
        ipvsadm -a -t ${VIP}:80 -r ${RIP[$i]}:80 -g
done
}
stop() {
        ifconfig eth0:0 ${VIP}/24 down
        ipvsadm -D -t ${VIP}:80
        arping -c 1 -I eth0 -s $VIP 192.168.100.254 >/dev/null 2>&1
}
case "$1" in
        start)
        start 
        action "ipvsd is starting" /bin/true
        ;;
        stop)
        stop 
        action "ipvsd is stoping" /bin/true
        ;;
        *)
        echo "Usage:$0 {start|stop}"
esac
